import { request } from '@umijs/max';
import { setAuthHeader } from '../utils/authInterceptor';

/**
 * 获取所有物资分类
 * @returns 物资分类列表
 */
export async function getCategoryList() {
  const headers: Record<string, string> = {
    'Content-Type': 'application/json',
  };
  
  // 添加认证头
  setAuthHeader(headers);
  
  return request('/api/category/list', {
    method: 'GET',
    headers,
  });
}

/**
 * 获取物资分类树结构
 * @returns 物资分类树结构
 */
export async function getCategoryTree() {
  const headers: Record<string, string> = {
    'Content-Type': 'application/json',
  };
  
  // 添加认证头
  setAuthHeader(headers);
  
  return request('/api/category/tree', {
    method: 'GET',
    headers,
  });
}

/**
 * 获取所有存放位置
 * @returns 存放位置列表
 */
export async function getLocationList() {
  const headers: Record<string, string> = {
    'Content-Type': 'application/json',
  };
  
  // 添加认证头
  setAuthHeader(headers);
  
  return request('/api/location/list', {
    method: 'GET',
    headers,
  });
}

/**
 * 获取存放位置树结构
 * @returns 存放位置树结构
 */
export async function getLocationTree() {
  const headers: Record<string, string> = {
    'Content-Type': 'application/json',
  };
  
  // 添加认证头
  setAuthHeader(headers);
  
  return request('/api/location/tree', {
    method: 'GET',
    headers,
  });
}